const http = require("http");
let weburl = "http://www.mobiletrain.org/?pinzhuanbdtg=guanwang";//需要爬的网址
const cheerio = require("cheerio");//第三方模块
const fs = require("fs");
http.get(weburl, req => {
    let str = "";
    req.on("data", chunk => {
        str += chunk;
    })
    req.on("end", chunk => {
        let $ = cheerio.load(str);
        let arr = [];
        $(".btn_content a").each((index, item) => {
            let obj = {
                title: $(item).text()
            }
            arr.push(obj);
        })
        fs.writeFileSync("data.json", JSON.stringify(arr))
    })
})
